/*
	This file is part of AVRCppLib.

    AVRCppLib is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    AVRCppLib is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with AVRCppLib.  If not, see <http://www.gnu.org/licenses/>.

    Copyright (C) Maxime Lemonnier 2007-2011
 */

#ifndef BufferTest_H_
#define BufferTest_H_

#include "DataStructures/Buffer.h"
#include "TestCase.h"
#include "../../TestClass.h"

class BufferTest :  public TestCase<BufferTest>
{
public:
	BufferTest(const prog_mem * testMethodName_P, TestCase<BufferTest>::TestMethod testMethod) :
	TestCase<BufferTest>(testMethodName_P, testMethod)
	{

	}

	Buffer<char> builder(const char * string)
	{
		Buffer<char> buf(10, string);

		Buffer<char> buf2 = buf;

		printf(buf2.buffer);

		return buf;
	}

	bool testConstructorsDestructors()
	{
		char string[] = "123456789";

		Buffer<char> * buf = new Buffer<char>(10, string);

		bool result = AVRUNIT_ASSERT(buf->buffer != string);

		result &= AVRUNIT_ASSERT(!isNull(buf->buffer));

		result &= AVRUNIT_ASSERT_EQUALS_LONG_AUTONAME(buf->numberOfElements, 10);

		delete buf;

		Buffer<char> buf2 = builder(string);

		result &= AVRUNIT_ASSERT_AUTONAME(!isNull(buf2.buffer));

		result &= AVRUNIT_ASSERT_EQUALS_STRING_NAMED_TESTVALUE(buf2.buffer, string);


		return result;
	}

};
#endif /* BufferTest_H_ */
